"""a collection module"""
__author__ = "张延强"

lst = ['python', 'java', 'c++']

print('张延强')
print(len(lst))

listtmp = [1, 2, 3, 4]
print(lst + listtmp)
# 重复元素
print(listtmp * 3)

# in
print('python' in lst)
# max min
print(max(listtmp))
print(min(listtmp))
# append
listtmp.append("like")
print(listtmp)
print(dir(list))

print(hasattr(listtmp, '__iter__'))
listtmp.extend(lst)
print(listtmp)
print(listtmp.count('java'))

# insert
listtmp.insert(1, 'test')
print(listtmp)
# pop
ele = listtmp.pop(1)
print(ele)
print(listtmp)
# remove
listtmp.remove('like')
print(listtmp)
# reverse
listtmp.reverse()
print(listtmp)

# sort
lst1 = ['java', 'beijing', 'shanghai', 'riben']
lst1.sort(reverse=True)
print(lst1)
# split
words = 'hello I am, from China'
print(words.split())
print(words.split(','))
print(words.split(',', 1))
# join
name = ['hello', 'I am', 'from ', 'China']
print('.'.join(name))
# tuple 元组
t = '1', 23, ['123', 12]
print(t)
# tuple list 抓换
t_list = list(t)
print(t_list)
tt = tuple(t_list)
print(tt)
# dict
person = {"name": "qiwsir", "site": "qiwsir.github.io", "language": "python"}
print(person['name'])
person['name2'] = 'zhangyanqiang'
person['name3'] = 'hobo'
print(person)

city_code = {"suzhou":"0512", "tangshan":"0315", "hangzhou":"0571"}
print("%(suzhou)s is very beautiful"%city_code)
# copy
name = 'zhang'
first = 'zhang'
print(id(name))
print(id(first))
# set
a_set = set(["python"])
print(a_set)
a_set.add("zhangyanqiang")
print(a_set)
b_set = set(["zhuyuanli"])
a_set.update(b_set)
print(a_set)
a_set.remove('zhuyuanli')
print(a_set)
# 集合计算
aa_set = set("python")
aasub = set('p')
print(aasub < aa_set)
bb_set = set("think")
print(aa_set | bb_set)
print(aa_set & bb_set)
print(aa_set and bb_set)
print(aa_set - bb_set)
# 运算符
print(9+10**2)
# if
a = 8
if a == 8:
    print(a)
